import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig({
  base: '/charts',
  plugins: [vue(),
  AutoImport({
    resolvers: [ElementPlusResolver()],
  }),
  Components({
    resolvers: [ElementPlusResolver()],
  }),],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  build: {
    target: ['chrome74'],
    // rollupOptions: {
    //   external: ['Enterpriseinformation'], // 将vue作为外部依赖
    //   // other rollup options...
    // }
  },
  server: {
    // 反向代理配置
    proxy: {
      "/api": {
        target: "http://bolin.xinpanmen.com/",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
  // devServer: {
  //   proxy: {
  //     // 配置第一个代理
  //     '/api': {
  //       target: 'http://bolin.xinpanmen.com/'
  //     },
  //     // 配置第二个代理
  //     '/ap2': {
  //       target: 'http://punan.xinpanmen.com:9002/'
  //     }
  //   }
  // }
});
